CREATE PROCEDURE coreCMSMapSave
(
	@id int output,
	@Domain nvarchar(500),
	@FK_Homepage int,
	@FK_Rootpage int
)
AS

IF @id = -1
BEGIN
	SET NOCOUNT ON;
	
	INSERT INTO ContentDomainMapping (Domain,FK_Homepage,FK_Rootpage)
	VALUES (@Domain, @FK_Homepage, @FK_Rootpage);
	
	SET NOCOUNT OFF;
	SELECT @id = @@IDENTITY;
END
ELSE
	UPDATE ContentDomainMapping SET 
		Domain=@Domain, 
		FK_Homepage=@FK_Homepage, 
		FK_Rootpage=@FK_Rootpage 
	WHERE PK_ID=@id;
